package com.sunshine.lnuplusweb.service.Impl;

import com.sunshine.lnuplusweb.dao.ScheduleMapper;
import com.sunshine.lnuplusweb.entities.Lesson;
import com.sunshine.lnuplusweb.entities.Schedule;
import com.sunshine.lnuplusweb.service.ScheduleService;
import com.sunshine.lnuplusweb.utils.CryptoUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 课表服务实现类
 */
@Service
public class ScheduleServiceImpl implements ScheduleService {
    @Resource
    private ScheduleMapper scheduleMapper;

    /**
     * 获取当前用户的课表信息
     * @param userId    用户名
     * @return          课表列表
     */
    @Override
    public List<Schedule> getScheduleByUser(String userId) {
        return scheduleMapper.getScheduleByUser(CryptoUtils.encrypByMD5(userId));
    }

    /**
     * 添加课表
     */
    @Override
    public void addSchedule(Schedule schedule) {
        scheduleMapper.insertSchedule(schedule.getScheduleId(), CryptoUtils.encrypByMD5(schedule.getUserId()), schedule.getScheduleName());
    }
}
